Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ART Local tests in the APIs #419

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

Conversation

zhaoyuyoung
Copy link
Contributor

No description provided.

Copy link
Contributor

@tkorchug tkorchug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will comment line by line, here is a few general comments mostly related to style:

  • please move any non-view functions from views.py to utils.py (i.e. get_client_ip)
  • you have misaligned comments e.g. lines 1166, 1169 it is harder to read code, please tab them to align with the next lines
  • I think the test_type for good jobs should be also set to "grid", right now it will be "None". And related to this, there should be an extra param in query in all existing views query['test_type'] = "grid", so bigpanda takes only grid tests from the DB by default for the transition period. I think setupView() function in art/utils.py is the perfect place to add it


# log all the req params for debug
_logger.debug('[ART] registerARTtest requestParams: ' + str(request.session['requestParams']))

# Checking whether params were provided
if 'test_type' in request.session['requestParams']:
test_type = request.session['requestParams']['test_type']

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here should be else: test_type = "grid", otherwise it end up as None. I think the "grid" should be default, at least it is needed before art expert adds this param to the art code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made "test_type" default to be "grid".

if 'requestParams' in request.session and 'pandaid' in request.session['requestParams'] and 'testname' in request.session['requestParams']:
pandaid = request.session['requestParams']['pandaid']
testname = request.session['requestParams']['testname']
elif test_type == 'local':
'''
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is python doc string, which is used in the beginning of each function. I the middle of the code it is better to use comments with "#"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected.

# If reverse DNS lookup fails, return the IP address as fallback
art_host = client_ip

if art_host.split('.')[0] in art_const.AUTHORIZED_HOSTS:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use of pass can be simplified by inverting the if statement, e.g.
if art_host.split('.')[0] not in art_const.AUTHORIZED_HOSTS:
return JsonResponse({"error": "Invalid ART API user!"}, status=403)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed "pass". (There were other contents here for test. I forgot to remove it in the first cleaning.).


# Generate job ID for ART Local
query = {'test_type': 'local'}
localIDs = []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here no need to get all pandaids from DB, it is sufficient to use aggregate functionality of Django ORM, there is an example of in remove_old_tests() view, it should be around line 1622.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to the Django ORM aggregration.

else:
pandaid = art_const.INITIAL_LOCAL_ID
_logger.info("JobID: {} was generated".format(pandaid))
testname = request.session['requestParams']['testname']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line is the same for both local and grid jobs, and it is duplicated with 1158, it is better to move it out of if statement.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now both local and grid have the commond code.

if 'jobname' in job:
# Only check ART Grid tests
if test_type and test_type == 'local':
branch = concat_branch({'nightly_release_short':nightly_release_short, 'project': project, 'platform': platform})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the same as testname, no need to have the same lines for both types of tests inside if. Please move it outside to avoid duplication.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both the local and grid tests have the same code for this too.

# Only check ART Grid tests
if test_type and test_type == 'local':
branch = concat_branch({'nightly_release_short':nightly_release_short, 'project': project, 'platform': platform})
attemptnr = 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be moved up to around 1187

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved.

if test_type and test_type == 'local':
branch = concat_branch({'nightly_release_short':nightly_release_short, 'project': project, 'platform': platform})
attemptnr = 1
else:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here it can be simple if test_type == "grid", instead of if-else, after the previous two lines moved to their places

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you have added test_type == "grid" to the existing jobs in the ART tables, this has been changed as suggested.

@@ -1265,6 +1316,8 @@ def registerARTTest(request):
_logger.exception('Failed to parse date from nightly_tag')

# Check whether the pandaid has been registered already
if test_type and test_type == 'local':
computingsite = "ART Local"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be also moved up to ~1187, to shorten code and avoid this if statement.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move as suggested.

)
insertRow.save()
data = {'exit_code': 0, 'message': "Provided pandaid has been successfully registered"}
data = {'exit_code': 0, 'PandaID': pandaid, 'message': "Provided pandaid has been successfully registered"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see why to used capital letters here, "pandaid" should be OK. And the message may be updated, something like "Test has been registered" or something like that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using pandaid in lower case now.

@zhaoyuyoung
Copy link
Contributor Author

zhaoyuyoung commented Dec 16, 2024 via email

@zhaoyuyoung
Copy link
Contributor Author

Thanks for your reviews! I've accomodated your suggestions to the new commit.
Since you have added "test_type" to all existing jobs in the ART tables, test_type="grid" is the default query now. This should help only display ART grid tests in the bigpanda.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants